package com.example.config;

import io.minio.MinioClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author thj
 * @date 2024-08-13
 */
@Configuration
public class MinioClientConfig {
    private final static Logger log = LoggerFactory.getLogger(MinioClientConfig.class);

    @Value("${minio.endpoint}")
    private String endpoint;

    @Value("${minio.accessKey}")
    private String accessKey;

    @Value("${minio.secretKey}")
    private String secretKey;

    @Value("${minio.bucketName}")
    private String bucketName;

    @Bean
    public MinioClient minioClient() {
        log.info("endpoint={}  ,  accessKey={}  ,secretKey={}", endpoint, accessKey, secretKey);
        return MinioClient.builder().credentials(accessKey, secretKey).endpoint(endpoint).build();
    }
}

